from app import db


class data_table(db.Model):
	__table__name = 'data_table'
	id = db.Column(db.INTEGER, primary_key=True, autoincrement=True)
	name = db.Column(name='name', nullable=False)
	hash_code = db.Column(name='hash_code', nullable=False)
	date = db.Column(name='date', nullable=False)
	positive = db.Column(name='positive', nullable=False)
	
	def to_dict(self):
		person = {
			"id": self.id,
			"name": nameChange(self.name),
			"hash_code": self.hash_code,
			"date": self.date,
			"positive": self.positive,
		}
		return person


class broadcast_history(db.Model):
	__table__name = 'broadcast_history'
	id = db.Column(db.INTEGER, primary_key=True, autoincrement=True)
	name = db.Column(name='name', nullable=False)
	hash_code = db.Column(name='hash_code', nullable=False)
	date = db.Column(name='date', nullable=False)
	positive = db.Column(name='positive', nullable=False)
	broadcast_date = db.Column(name='broadcast_date', nullable=False)
	
	def to_dict(self):
		person = {
			"id": self.id,
			"name": self.name,
			"hash_code": self.hash_code,
			"date": self.date,
			"broadcast_date": self.broadcast_date,
			"positive": self.positive,
		}
		return person


def nameChange(name):
	s = list(name)
	for i in range(len(s)):
		if i >= 1:
			s[i] = ' *'
	b = ''.join(s)
	return b
